<?php

	// +----------------------------------------------------------------------
	// | 商品日志
	// +----------------------------------------------------------------------
	// | Copyright (c) 2015-2024 http://www.yicmf.com, All rights reserved.
	// +----------------------------------------------------------------------
	// | Author: 微尘 <yicmf@qq.com>
	// +----------------------------------------------------------------------

	namespace app\model\store;

	class GoodLog extends Common
	{

		/**
		 * 关联模型
		 * @author  : 微尘 <yicmf@qq.com>
		 */
		public function good()
		{
			return $this->belongsTo(Good::class);
		}

		// 类型转换
		protected $type = [
			'data' => 'array'
		];
		public function store()
		{
			return $this->belongsTo(Store::class);
		}

		public function goodSku()
		{
			return $this->belongsTo(GoodSku::class);
		}


		/**
		 * 写入修改
		 * @param $data
		 */
		public static function onBeforeInsert($data)
		{
			$data['status'] = 1;
			$data['ip'] = request()->ip();
			$data['os'] = request()->server('HTTP_USER_AGENT');
		}

	}
